package com.example.win.android_banduyujia.manager;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by Win on 2015/8/6.线程管理类，最多可同时执行5个线程。
 */
public class ExecutorsManager {

    private static final int MAS_THREAD_POOL_SIZE = 5;
    private static ExecutorsManager  mInstance;
    private ExecutorService  mExecutorService;

    public ExecutorsManager(){
        mExecutorService = Executors.newFixedThreadPool(MAS_THREAD_POOL_SIZE);
    }

    public static ExecutorsManager getInstance(){
        if(mInstance == null){
            mInstance = new ExecutorsManager();
        }
        return mInstance;
    }

    /**
     * 执行线程
     * @param
     */
    public void excute(Runnable command) {
        mExecutorService.execute(command);
    }
}
